package com.tanhua.server.controller;

import com.tanhua.domain.vo.Answers;
import com.tanhua.domain.vo.QuestionnaireVo;
import com.tanhua.domain.vo.ReportVo;
import com.tanhua.server.service.TestSoulService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
import java.util.Set;


@RestController
@RequestMapping("/testSoul")
public class TestSoulController {
    @Autowired
    private TestSoulService testSoulService;
    /**
     * 测灵魂-问卷列表
     * 接口路径：GET/testSoul
     */
    @GetMapping
    public ResponseEntity<Object> questionnaireList(){
        List<Object> list =  testSoulService.queryQuestionnaire();

        return ResponseEntity.ok(list);
    }

    /**
     * 测灵魂-提交问卷（学生实战）
     * 接口路径：POST/testSoul
     */
    @PostMapping
    public ResponseEntity<Object> submitQuestionnaire(@RequestBody Map<String, List<Answers>> answers){
        String score = testSoulService.queryScore(answers);
        return ResponseEntity.ok(score);
    }

    /**
     * 测灵魂-查看结果（学生实战）
     * 接口路径：GET/testSoul/report/:id
     */
    @GetMapping("report/{id}")
    public ResponseEntity<Object> queryResults (@PathVariable("id") String id){
        ReportVo reportVo = testSoulService.queryResults(id);
        return ResponseEntity.ok(reportVo);
    }
}
